﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第106题
//BC108 矩阵交换
//https://www.nowcoder.com/practice/ec44d4ff8c794b2f9205bdddbde96817?tpId=107&tqId=33389&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D3%26tpId%3D107%26type%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <stdio.h>

int main() {
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    char ch;//接受t字符
    int arr[10][10] = { 0 };

    //输入
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &arr[i][j]);
        }
    }

    int k = 0;
    int index1 = 0;
    int index2 = 0;
    scanf("%d", &k);
    //操作k次
    for (int count = 0; count < k; count++) {
        scanf(" %c %d %d", &ch, &index1, &index2);
        //注意下标都要减去1
        index1--;
        index2--;
        if (ch == 'r') {
            //行变换，列自增加，行不变
            for (int j = 0; j < n; j++) {
                int temp = arr[index1][j];
                arr[index1][j] = arr[index2][j];
                arr[index2][j] = temp;
            }
        }
        else if (ch == 'c') {
            //列变换，行自增加，列不变
            //注意下标都要减去1
            for (int i = 0; i < n; i++) {
                int temp = arr[i][index1];
                arr[i][index1] = arr[i][index2];
                arr[i][index2] = temp;
            }
        }
        else {
            continue;
        }
    }

    //输出
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}